package com.yk.airline.component.analysisdata.impl;

import com.yk.airline.component.analysisdata.api.ICommonAnalysis;
import com.yk.airline.dao.capturemark.api.ICaptureMarkDao;
import com.yk.airline.dao.origindata.api.IOriginDataDao;
import com.yk.airline.model.CaptureMarkModel;
import com.yk.airline.model.OriginDataModel;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import javax.annotation.Resource;
import java.util.List;

/**
 * Project Name:airlinecrawler
 * File Name:CommonAnalysisImpl
 * Package Name:com.yk.airline.component.analysisdata.impl
 * Date:2018/2/1 10:00
 * Author:dengtianjia
 * Description:
 * Copyright (c) 2018, 重庆云凯科技有限公司 All Rights Reserved.
 */
public abstract class CommonAnalysisImpl implements ICommonAnalysis {

    @Resource(name = "originDataDao")
    private IOriginDataDao originDataDao;

    @Resource(name = "captureMarkDao")
    private ICaptureMarkDao captureMarkDao;

    @Override
    public List<OriginDataModel> findOriginDataByCaptureMark(CaptureMarkModel mark) {
        CaptureMarkModel theLatestMark = captureMarkDao.findTheLatestMark();
        return originDataDao.findByCaptureMark(theLatestMark);
    }

    @Override
    public Elements getAllParentElement(String html, String path) {
        Document parse = Jsoup.parse(html);
        return parse.select(path);
    }


}
